home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / instools / prelude.zip / LINGUA13.EXE / LINGUA.DOC < prev    next >
Text File  |  1994-02-17  |  11KB  |  261 lines

  1. ---- LINGUA -- MULTILANGUAGE SUPPORT FOR YOUR PROGRAMS -- SHAREWARE ----
  2. -- VERSION 1.3 -- (C) 1994 -- SICHEMSOFT -- WAGENINGEN -- NETHERLANDS --
  3.  
  4. The LINGUA package is designed to help C-programmers to develop applications
  5. that must be released in multiple languages. The end user gets a program
  6. plus one or more datafiles containing all text in the program. One
  7. datafile for each different language. A language can be chosen at
  8. run time. This thus avoids different .exe files for different languages.
  9. The programmer needs only to compile one executable and to make a text data
  10. file for every supported language. It's also easy to afterwards create
  11. support for yet another language and send the data file to interested
  12. customers.
  13.  
  14.  
  15. HOW IT WORKS
  16.  
  17. The package consists of a program, LINGUA, and a module, UI_TEXT (UI
  18. stands for User Interface). The module should be compiled and linked with
  19. your application program. This module is the same for any language and
  20. is very small (about 3.5KB when compiled with Borland C++ 3.1 under MSDOS).
  21. For every supported language a text file is prepared by the programmer
  22. according to a specified format. This text file is then encrypted by LINGUA,
  23. so users cannot alter and perhaps corrupt it just by editing it. These
  24. encrypted text files are shipped with the application and one of them is
  25. loaded by the module UI_TEXT at run time so the application speaks the
  26. desired language.
  27.  
  28.  
  29. FILES IN THE PACKAGE
  30.  
  31. LINGUA.DOC        You're reading it
  32. LINGUA.EXE        Utility to encrypt .TXT file to .ETF file
  33. LINGUA.C          Source of the above
  34. UI_TEXT.OBJ       Module to be linked with your application (large model)
  35. UI_TEXT.C         Source of the above
  36. LINGDEMO.EXE      Small demo program, usage e.g.: lingdemo francais
  37. LINGDEMO.C        Source of the above
  38. LINGUA.H          Include file for compilation of lingua.c and ui_text.c
  39. ETFTEST.EXE       Utility to show contents of .ETF file
  40. ETFTEST.C         Source of the above
  41. FILES.INC         Include file for ui_text.c, replace if desired (see below)
  42. MAKEFILE          Makefile for the above programs (DOS/BC++)
  43. UNIX.MAK          Makefile for the above programs (UNIX)
  44. NOCR.C            Source for carriage-return/end-of-file remover for UNIX
  45. ENGLISH.TXT       Text files for demo program
  46. FRANCAIS.TXT
  47. DEUTSCH.TXT
  48. NL.TXT
  49. ENGLISH.ETF       Encrypted files for demo program
  50. DEUTSCH.ETF
  51. FRANCAIS.ETF
  52. NL.ETF
  53. UI_TEXT.H         Header file created by LINGUA from .txt files above
  54.  
  55. The file FILES.INC defines all file functions for ui_text.c. FILES.INC uses
  56. the standard C library file functions, like fopen, fseek etc. If you wish
  57. to use other file functions, or C++ streams functions, or whatever, you can
  58. write your own FILES.INC with these functions.
  59.  
  60.  
  61. USAGE
  62.  
  63. First of all, do not use ANY literal strings in your C-source, but
  64. always use identifiers, e.g. not "Press any key" but ANYKEY.
  65. Write your program in any way you like while observing this main rule.
  66.  
  67. At the same time create and maintain a text file with all literal
  68. text for the program in your native language. This file may have any
  69. name but its extension should be .TXT for use by LINGUA. The lines in
  70. this text file should all begin (at the first position!) with an identifier,
  71. corresponding to the identifiers used in the program. Behind the identifier
  72. follows the literal string that should be used in run time. Comment lines
  73. are allowed, they must begin with #. In the literal strings _ signifies
  74. a leading or trailing space, and - denotes an empty string. String arrays,
  75. in which not every item has its own name, are represented by [ after an
  76. identifier's name followed by one or more lines starting with only [.
  77. Multiline strings are represented by / after an identifier's name followed
  78. bye one or more lines starting with only /.
  79.  
  80. By default the text is loaded all at once into memory at the start of the
  81. application (or rather by calling ui_loadtext) and deleted at the end of
  82. the application (ui_unloadtext). If desired, part or all of the text can
  83. be read from the file only when necessary. For this, use the directive
  84. #FILE in the text file (see example below). All text after this directive
  85. will only be loaded when necessary. All text before #FILE remains resident
  86. in memory. You could place all frequently used strings before #FILE and
  87. seldom used or very long strings after #FILE. If #FILE is used the text
  88. file will remain open between ui_loadtext and ui_unloadtext.
  89.  
  90. Example file english.txt:
  91.  
  92. #english.txt
  93. #empty string
  94. ZEROTH     -
  95. #normal strings
  96. FIRST     one
  97. SECOND    two times
  98. #array
  99. THIRD[    three
  100. [         four
  101. [         five
  102. [         -
  103. [         seven
  104. #leading and trailing spaces
  105. EIGHTH    __eight__
  106. #FILE
  107. #normal string again
  108. NINTH     nine
  109. #multi line string
  110. TENTH/    this is
  111. /         a multiline
  112. /         tenth string
  113. #that's it!
  114. ELEVEN    eleven
  115.  
  116. Whenever any identifier in this text file has been added/edited/deleted,
  117. run the utility LINGUA, like:
  118.  
  119. lingua english
  120.  
  121. and recompile (like you would also have to do if you had edited
  122. literal strings in your source code).
  123.  
  124. LINGUA creates two files: english.etf and ui_text.h (ETF stands for
  125. Encrypted Text File). The header file UI_TEXT.H must be included in the
  126. source file that takes care of the loading and unloading of the text
  127. at run time. Since this header is not language dependent, no
  128. recompilation for another language is necessary. It contains only
  129. defines for all identifiers as show below.
  130.  
  131. Example file ui_text.h:
  132.  
  133. /* ui_text.h */
  134.  
  135. int ui_loadtext(char *fname,char *vers);
  136. void ui_unloadtext(void);
  137. char *ui_filetext(unsigned pos);
  138. char **ui_filearray(unsigned pos);
  139. extern char **ui_text;
  140.  
  141. #define ZEROTH                         ui_text[0]
  142. #define FIRST                          ui_text[1]
  143. #define SECOND                         ui_text[2]
  144. #define THIRD                          (ui_text+3)
  145. #define EIGHTH                         ui_text[8]
  146. #define NINTH                          ui_filetext(0)
  147. #define TENTH                          ui_filetext(1)
  148. #define ELEVEN                         ui_filetext(2)
  149.  
  150. When your application is finished, make a copy of the original .TXT
  151. file and change the literal strings in the copy to another language.
  152. Be careful not to change the identifiers at the start of every line though!
  153. When you run LINGUA on this text file a new .ETF file is created
  154. (and also a ui_text.h, but this one is identical to the one in the
  155. original language).
  156.  
  157. In the application program, start with a call to ui_loadtext (in
  158. the UI_TEXT module). End the application program with a call to
  159. ui_unloadtext. Another language may be loaded at that point too.
  160. Lingua also writes a checksum at the start of the .ETF file. ui_loadtext
  161. returns 1 if the file was read and decoded successfully and the
  162. computed checksum is equal to the one in the file and 0 if not.
  163. You can then handle an error condition in your application (but
  164. in what language?).
  165.  
  166. Example file lingdemo.c (link with ui_text.c):
  167.  
  168. #include <stdio.h>
  169. #include <string.h>
  170. #include "ui_text.h"
  171.  
  172. int main(int argc,char *argv[])
  173. {
  174.    char filename[81],version[81];
  175.  
  176.    if (argc>3) return 1;
  177.    if (argc==3) strcpy(version,argv[2]); else version[0]='\0';
  178.    if (argc>=2) strcpy(filename,argv[1]); else strcpy(filename,"english");
  179.  
  180.    if (ui_loadtext(filename,version)) {
  181.       printf("%s",FIRST);
  182.       printf("%s",SECOND);
  183.       printf("%s",THIRD[0]);
  184.       printf("%s",THIRD[1]);
  185.       printf("%s",THIRD[2]);
  186.       printf("%s",THIRD[3]);
  187.       printf("%s",THIRD[4]);
  188.       printf("%s",EIGHTH);
  189.       printf("%s",NINTH);
  190.       printf("%s",TENTH);
  191.       printf("%s",ELEVEN);
  192.       ui_unloadtext();
  193.    } else puts("Fatal error");
  194.    return 0;
  195. }
  196.  
  197. Execute this example program by:
  198.  
  199. lingdemo <name of etf-file without extension>
  200.  
  201. e.g.:
  202.  
  203. lingdemo english
  204.  
  205. If so desired an optional version number (or other string) may be
  206. given as second argument for the LINGUA utility. This same version
  207. number should then be used as the second parameter in the call
  208. to ui_loadtext. This can be use